package com.rickpan.dto.request;

import com.fasterxml.jackson.annotation.JsonFormat;
import com.rickpan.entity.TeamMember;
import io.swagger.v3.oas.annotations.media.Schema;
import jakarta.validation.constraints.Future;
import jakarta.validation.constraints.Min;
import jakarta.validation.constraints.Max;

import java.time.LocalDateTime;

/**
 * 生成邀请码请求DTO
 */
@Schema(description = "生成邀请码请求")
public class GenerateInviteCodeRequest {

    @Schema(description = "邀请角色", example = "MEMBER", allowableValues = {"ADMIN", "MEMBER"})
    private TeamMember.Role inviteRole = TeamMember.Role.MEMBER;

    @Schema(description = "过期时间", example = "2025-01-18T10:00:00")
    @Future(message = "过期时间必须是未来时间")
    @JsonFormat(pattern = "yyyy-MM-dd'T'HH:mm:ss")
    private LocalDateTime expireTime;

    @Schema(description = "最大使用次数", example = "10", minimum = "1", maximum = "100")
    @Min(value = 1, message = "最大使用次数至少为1")
    @Max(value = 100, message = "最大使用次数不能超过100")
    private Integer maxUses;

    // 构造函数
    public GenerateInviteCodeRequest() {}

    public GenerateInviteCodeRequest(TeamMember.Role inviteRole, LocalDateTime expireTime, Integer maxUses) {
        this.inviteRole = inviteRole;
        this.expireTime = expireTime;
        this.maxUses = maxUses;
    }

    // Getter和Setter方法
    public TeamMember.Role getInviteRole() {
        return inviteRole;
    }

    public void setInviteRole(TeamMember.Role inviteRole) {
        this.inviteRole = inviteRole;
    }

    public LocalDateTime getExpireTime() {
        return expireTime;
    }

    public void setExpireTime(LocalDateTime expireTime) {
        this.expireTime = expireTime;
    }

    public Integer getMaxUses() {
        return maxUses;
    }

    public void setMaxUses(Integer maxUses) {
        this.maxUses = maxUses;
    }

    @Override
    public String toString() {
        return "GenerateInviteCodeRequest{" +
                "inviteRole=" + inviteRole +
                ", expireTime=" + expireTime +
                ", maxUses=" + maxUses +
                '}';
    }
}
